package studentprogressreport;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Class represents curriculum entity.
 * <p>
 * The class Curriculum provides constructor and methods for getting
 * curriculum's name, adding new courses to curriculum and calculating courses
 * duration.
 * 
 * @author Nadejda Makarkina
 */

public class Curriculum {
	private String name;
	private Collection<Course> courses = new ArrayList<Course>();

	/**
	 * Initializes a newly created <code>Curriculum</code> object.
	 * 
	 * @param curriculumName
	 */
	public Curriculum(String curriculumName) {
		name = curriculumName;
	}

	/**
	 * Add new course to the Curriculum object.
	 * 
	 * @param courseName
	 * @param duration
	 */
	public void addCourse(String courseName, Integer duration) {
		courses.add(new Course(courseName, duration));
	}

	/**
	 * Returns the name of the Curriculum object.
	 * 
	 * @return name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns duration of the curriculum. Duration is summarizes courses
	 * duration.
	 * 
	 * @return summarized courses duration
	 */
	public int calculateCourseDuration() {
		int count = 0;
		for (Course item : courses) {
			count = count + item.getDuration();
		}
		return count;
	}
}
